package my.action.author;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import my.controller.Action;
import my.controller.ActionForward;
import my.db.DAO.ArticleDAO;
import my.db.DAO.ArticleTypeDAO;
import my.db.DAO.AuthorDAO;
import my.db.DTO.ArticleTypeDTO;
import my.db.DTO.AuthorDTO;

public class AuthorListAction implements Action{

	@Override
	public ActionForward execute(HttpServletRequest request,HttpServletResponse response) throws Exception {
		ArrayList<AuthorDTO> list_au=new ArrayList<AuthorDTO>();
		
		AuthorDAO adao=new AuthorDAO();
		ArticleTypeDAO artdao=new ArticleTypeDAO();
		ActionForward forward=new ActionForward();
		
		int start, stop, rows, pages;
		String keyword;;
		
		rows = Integer.parseInt(request.getParameter("rows"));
		pages = Integer.parseInt(request.getParameter("pages"));
		
		keyword=request.getParameter("keyword");
		start = (rows * (pages - 1)) + 1;
		stop = rows * pages;
		
		AuthorDAO o=new AuthorDAO();
		list_au=o.getListAuthor(start,stop,keyword);
		request.setAttribute("list_author", list_au);
		
		forward.setPath("./admin_page.jsp");
			
		forward.setRedirect(false);
		return forward;
	}

}
